package com.online.onlinestudent.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.online.onlinestudent.entity.Comment;
import com.online.onlinestudent.mapper.CommentMapper;
import com.online.onlinestudent.service.CommentService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {

    @Override
    public List<Comment> getCommentsByCourseId(Long courseId) {
        QueryWrapper<Comment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("course_id", courseId);
        List<Comment> list = baseMapper.selectList(queryWrapper);
        if (list.isEmpty()||list==null){
            return new ArrayList<>();
        }
        return list;
    }
}
